var DataTables = function () {
    return {
        catalogTable:function () {
            $('#catalogTable').DataTable({
                serverSide:true,
                paginate:true,
                processing:true,
                ordering:false,
                autoWidth:true,
                language: {
                    "sProcessing": "处理中...",
                    "sLengthMenu": "显示 _MENU_ 项结果",
                    "sZeroRecords": "没有匹配结果",
                    "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                    "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                    "sInfoPostFix": "",
                    "sSearch": "搜索:",
                    "sUrl": "",
                    "sEmptyTable": "表中数据为空",
                    "sLoadingRecords": "载入中...",
                    "sInfoThousands": ",",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "上页",
                        "sNext": "下页",
                        "sLast": "末页"
                    },
                    "oAria": {
                        "sSortAscending": ": 以升序排列此列",
                        "sSortDescending": ": 以降序排列此列"
                    }
                },
                order: [[1, 'asc']],
                lengthMenu: [
                    [5, 10, 15, 20],
                    [5, 10, 15, 20] // change per page values here
                ],
                pageLength: 5,
                columns:[{
                    data:"id",
                    visible:false
                },{
                    data:"className",
                    title:"类目名称"
                },{
                    data:"type",
                    title:"类目类型"
                },{
                    data:"remark",
                    title:"描述"
                },{
                    data: null,
                    title:'操作',
                    width:'15%'
                }],
                ajax:  {
                    url:"/api/catalog/findCataLogByPage",
                    type:"post",
                    data:function (dataSet) {
                        var param = {};
                        param.draw = dataSet.draw;
                        param.start = dataSet.start;
                        param.length = dataSet.length;
                        param.search=dataSet.search.value;
                        return param;
                    }
                },
                columnDefs: [
                    {
                        targets: -1,
                        render:function(data, type, row, meta){
                            return "<div class='btn-group'>"+
                                "<button id='setupAttributeBtn' class='btn btn-primary'  onclick='CataLog.showSetupAttribute("+data.id+")'>属性设置</button>"+
                                "<button id='deleteBtn' class='btn btn-primary' onclick='CataLog.deleteCatLog("+data.id+")'>删除</button>"+
                                "</div>";
                        }
                    }
                ]

            });

        },
        attributeTable:function () {
            $('#attributeTable').DataTable({
                serverSide:true,
                paginate:true,
                processing:true,
                ordering:false,
                autoWidth:false,
                language: {
                    "sProcessing": "处理中...",
                    "sLengthMenu": "显示 _MENU_ 项结果",
                    "sZeroRecords": "没有匹配结果",
                    "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                    "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                    "sInfoPostFix": "",
                    "sSearch": "搜索:",
                    "sUrl": "",
                    "sEmptyTable": "表中数据为空",
                    "sLoadingRecords": "载入中...",
                    "sInfoThousands": ",",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "上页",
                        "sNext": "下页",
                        "sLast": "末页"
                    },
                    "oAria": {
                        "sSortAscending": ": 以升序排列此列",
                        "sSortDescending": ": 以降序排列此列"
                    }
                },
                order: [[1, 'asc']],
                lengthMenu: [
                    [5, 10, 15, 20],
                    [5, 10, 15, 20] // change per page values here
                ],
                pageLength: 5,
                columns:[{
                    data:"id",
                    visible:false
                },{
                    data:"name",
                    title:"属性名称"
                },{
                    data:"pid",
                    title:"PID"
                },{
                    data: null,
                    title:'操作',
                    width:'20%'
                }],
                ajax:  {
                    url:"/api/catalog/findDataAttributeByPage",
                    type:"post",
                    data:function (dataSet) {
                        var param = {};
                        param.draw = dataSet.draw;
                        param.start = dataSet.start;
                        param.length = dataSet.length;
                        param.search= dataSet.search.value;
                        return param;
                    }
                },
                columnDefs: [
                    {
                        targets: -1,
                        render:function(data, type, row, meta){
                            return "<div class='btn-group'>"+
                                "<button id='setupAttributeBtn' class='btn btn-primary'  onclick='CataLog.showAddAttribute("+data.id+")'>属性编辑</button>"+
                                "<button id='deleteBtn' class='btn btn-primary' onclick='CataLog.deleteAttribute("+data.id+")'>删除</button>"+
                                "</div>";
                        }
                    }
                ]

            });

        }
    }
}();